//
//  TestSwiftA.swift
//  CooperSwift_Example
//
//  Created by 计海峰 on 2021/5/7.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import UIKit

class TestSwiftAVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        
        //
        func doubler(i: Int) -> Int { return i * 2 }
        let doublerAlter = { (i: Int) -> Int in
            var t = i * 2
            t = t + 2
            return t * 2
        }
        print([1,2,3,4].map(doubler))
        print([1,2,3,4].map(doublerAlter))
        
        debugPrint(randomInt())
        
        
        
        
        // Do any additional setup after loading the view.
    }
    
    
    func funcTest() -> Void {
        [1, 2, 3].map( { (i: Int) -> Int in return i * 2 } )
        [1, 2, 3].map( { i in return i * 2 } )
        [1, 2, 3].map( { i in i * 2 } )
        [1, 2, 3].map( { $0 * 2 } )
        [1, 2, 3].map() { $0 * 2 }
        [1, 2, 3].map { $0*2 }
    }
    
    func randomInt() -> [Int] {
        return (0...3).map{_ in Int.random(in: 1..<100)}
    }
    
}
